package com.jcx.ldzj.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jcx.ldzj.dao.DictionariesDataMapper;
import com.jcx.ldzj.entity.DictionariesData;
import com.jcx.ldzj.service.IDictionariesDataService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 码值表 服务实现类
 * </p>
 *
 * @author ld
 * @since 2021-07-19
 */
@Slf4j
@Service
public class DictionariesDataServiceImpl extends ServiceImpl<DictionariesDataMapper, DictionariesData> implements IDictionariesDataService {

    @Override
    public int countData(List<String> list) {
        return this.baseMapper.countData(list);
    }

    /**
     * @param page 分页
     * @param data 参数条件
     * @return
     */
    @Override
    @CachePut(value = "list",key = "#dicnarsId.concat(#data)",condition="#list!=null")
    public IPage<DictionariesData> getList(IPage<DictionariesData> page, DictionariesData data) {
        IPage<DictionariesData> list = this.baseMapper.getList(page, data);
        return list;
    }

    @Override
    @Cacheable(value = "dictionariesDatas",key = "#dicnarsId")
    public List<DictionariesData> getDicdataByType(Integer dicnarsId) {
        List<DictionariesData> dictionariesDatas = this.baseMapper.getDicdataByType(dicnarsId);
        return dictionariesDatas;
    }
}
